//
//  ZHFListHeadView.m
//  GoTraveling
//
//  Created by dllo on 15/12/26.
//  Copyright © 2015年 开发华佗. All rights reserved.
//

#import "ZHFListHeadView.h"

@interface ZHFListHeadView ()

@property (nonatomic, strong)UIImageView *headImageView;
@property (nonatomic, strong)UIImageView *iconImageView;
@property (nonatomic, strong)UILabel *nameLabel;
@property (nonatomic, strong)UILabel *contentLabel;
@property (nonatomic, strong)UIImageView *playImageView;
@property (nonatomic, strong)UILabel *playCountLabel;

@end

@implementation ZHFListHeadView

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    
    UIView *nilView = [[UIView alloc] initWithFrame:CGRectMake(0, self.frame.size.height - 1, SCREEN_WIDTH, 1)];
    nilView.backgroundColor = [UIColor colorWithRed:0.882 green:0.835 blue:0.722 alpha:1.000];
    [self addSubview:nilView];
    
    self.headImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, 170 * ADAPT_HEIGHT)];
    //    self.headImageView.backgroundColor = [UIColor yellowColor];
    self.headImageView.image = [UIImage imageNamed:@"trip_edit_empty_content@2x.png"];
    [self addSubview:self.headImageView];
    
    self.iconImageView = [[UIImageView alloc] initWithFrame:CGRectMake(20, self.headImageView.frame.size.height + 25 * ADAPT_HEIGHT, 30 * ADAPT_WIDTH, 30 * ADAPT_WIDTH)];
    self.iconImageView.image = [UIImage imageNamed:@"iconfont-touxiang.png"];
    self.iconImageView.layer.masksToBounds = YES;
    self.iconImageView.layer.cornerRadius = self.iconImageView.frame.size.width / 2;
    self.iconImageView.layer.borderWidth = 0;
    self.iconImageView.layer.borderColor = [UIColor colorWithRed:0.882 green:0.835 blue:0.722 alpha:1.000].CGColor;
    [self addSubview:self.iconImageView];
    
    self.nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImageView.frame.origin.x + self.iconImageView.frame.size.width + 5 * ADAPT_WIDTH, self.iconImageView.frame.origin.y + 5 * ADAPT_HEIGHT, SCREEN_WIDTH / 2, self.iconImageView.frame.size.height - 10 * ADAPT_HEIGHT)];
    self.nameLabel.textColor = [UIColor colorWithRed:0.49 green:0.57 blue:0.67 alpha:1];
    self.nameLabel.font = [UIFont systemFontOfSize:14];
    [self addSubview:self.nameLabel];
    
    self.playImageView = [[UIImageView alloc] initWithFrame:CGRectMake(self.iconImageView.frame.origin.x + self.iconImageView.frame.size.width + SCREEN_WIDTH / 1.5, self.nameLabel.frame.origin.y, 30 * ADAPT_WIDTH, 30 * ADAPT_WIDTH)];
    self.playImageView.image = [UIImage imageNamed:@"iconfont-shengyin.png"];
    [self addSubview:self.playImageView];
    
    self.playCountLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.playImageView.frame.origin.x + self.playImageView.frame.size.width + 5 * ADAPT_WIDTH, self.playImageView.frame.origin.y, 100 * ADAPT_WIDTH, self.playImageView.frame.size.height)];
    self.playCountLabel.textColor = [UIColor colorWithRed:0.82 green:0.82 blue:0.82 alpha:1];
    self.playCountLabel.font = [UIFont systemFontOfSize:11];
    [self addSubview:self.playCountLabel];
    
    self.contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.iconImageView.frame.origin.x, self.iconImageView.frame.origin.y + self.iconImageView.frame.size.height + 20 * ADAPT_HEIGHT, SCREEN_WIDTH - self.iconImageView.frame.origin.x * 2, SCREEN_HEIGHT * 0.05)];
    self.contentLabel.textColor = [UIColor colorWithRed:0.45 green:0.45 blue:0.45 alpha:1];
    self.contentLabel.font = [UIFont systemFontOfSize:14];
 
    [self addSubview:self.contentLabel];
    
}

-(void)setRadioInfo:(ZHFRadioInfo *)radioInfo{
    
    [self.headImageView sd_setImageWithURL:[NSURL URLWithString:radioInfo.coverimg] placeholderImage:[UIImage imageNamed:@"trip_edit_empty_content@2x.png"]];
    [self.iconImageView sd_setImageWithURL:[NSURL URLWithString:[self.radioInfo.userinfo objectForKey:@"icon"]] placeholderImage:[UIImage imageNamed:@"iconfont-touxiang.png"]];
    self.nameLabel.text = [radioInfo.userinfo objectForKey:@"uname"];
    self.contentLabel.text = radioInfo.desc;
    self.playCountLabel.text = [NSString stringWithFormat:@"%@",radioInfo.musicvisitnum];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
